﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WOWMultiPlay
{
    public partial class Form_Options : Form
    {
        public Form_Options()
        {
            InitializeComponent();
        }

        private void Form_Options_Load(object sender, EventArgs e)
        {
            LoadUserSettings();
        }

        private void LoadUserSettings()
        {
            tbAppOpacity.Text = Settings.UserSettings.AppOpacity.ToString();
            tbProcessName.Text = Settings.UserSettings.ProcessName;
            tbInterval_KeyPress.Text = Settings.UserSettings.Interval_KeyPress.ToString();
            tbInterval_KeyDown_Up.Text = Settings.UserSettings.Interval_KeyDown_Up.ToString();
            tbMaxButtonCountPerLine.Text = Settings.UserSettings.MaxButtonCountPerLine.ToString();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                Settings.UserSettings.AppOpacity = double.Parse(tbAppOpacity.Text);
                Settings.UserSettings.ProcessName = tbProcessName.Text;
                Settings.UserSettings.Interval_KeyPress = new mpTime(tbInterval_KeyPress.Text);
                Settings.UserSettings.Interval_KeyDown_Up = new mpTime(tbInterval_KeyDown_Up.Text);
                Settings.UserSettings.MaxButtonCountPerLine = int.Parse(tbMaxButtonCountPerLine.Text);

                Serializer<UserSettings>.Serialize(Settings.UserSettings, Settings.SettingsFilePath);
            }
            catch
            {
                MessageBox.Show("Invalid value.");
            }
        }
    }
}